This README file contains instructions for reproducing the results in Kendall (2021), "Herding and Contrarianism: A Matter of Preference?", as well as the results in the associated online appendix.

To reproduce the results:

1. Run processdata.m in Matlab. This is the master script which does most of the analysis:

	a. Figures 3 and 6 make up Figure 2 in the paper.
	b. Figure 4 corresponds to Figure 3 in the paper.
	c. Figure 5 corresponds to Figure 1 in the appendix.
	d. Figure 7 corresponds to Figure 3 in the appendix.
	e. Various statistics are reported (correlations, hypotheis 	tests, etc.).
	f. It outputs a file called parseddata.csv which is used by 	Stata.
	g. It outputs actual_beliefs.mat and pt_parameters.mat which 	are used in the market simulations.

2. Run analysis.do in Stata. It:
	a. Produces the data for Table 1 in the paper (also used in 	Table 4 of the paper).
	b. Reports results of logit regressions checking for 	increase in herding with price, etc.
	c. Reports results for path-dependent behavior.
	d. Reports results for tests of the Gambler's fallacy across 	rounds (not reported in paper).
	e. Reports rank sum tests for ccomparisons across 	treatments.

3. Run marketsims.m in Matlab. It should be run twice (once with modalonly = 0 and once with modalonly = 1) to produce the simulation results in Figure 2 of the appendix. 

4. Run calibration.m. It uses the data from daily returns NYSE.csv (obtained from CRSP) to produce the results of Section G of the Appendix (Tables 1 and 2). Note that the results may differ slightly due to the bootstrapping process.
 